<?php

class CActiveRecordData
{
	public static function getList($objArr, $key)
	{
		$resArray = array();

		if (count($objArr) > 0) {
			foreach ($objArr as $val) {
				$resArray[] = $val->{$key};
			}
		}
		
		return $resArray;
	}
	
	public static function getArray($objArr, $keys = false, $associative = true)
	{
		$resArray = array();
		
		if (count($objArr) > 0) {
			foreach ($objArr as $val) {
				if ($keys === false || !is_array($keys)) {
					if ($associative) {
						$resArray[] = $val->attributes;
					} else {
						$resArray[] = array_values($val->attributes);
					}
				} else {
					$subArray = array();
					foreach ($keys as $k => $v) {
						$subArray[$v] = $val->{$v}; 
					}
					if ($associative) {
						$resArray[] = $subArray;
					} else {
						$resArray[] = array_values($subArray);
					}
				}
			}
		}
		
		return $resArray;
	}
}